package battleship.model;
/**
 * 
 * @author Cameron McLeod
 * @version 1.0
 */
public class Grid {
	public Cell[][] TheGrid;
	/**
	 * Creates a new grid object and initializes the cell
	 */
	public Grid(){
		TheGrid = new Cell [10][10];
		
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				TheGrid[i][j] = new Cell();
			}
		}
	}
	/**
	 * 
	 * @param TheShot The shot that was fired at the grid
	 * @return if the spot targeted is occupied
	 */
	public boolean CheckOccupied(Shot TheShot){
		return TheGrid[TheShot.x][TheShot.y].IsOccupied();
	}
	/**
	 * 
	 * @param x The x coordinate on the grid
	 * @param y The y Coordinate on the grid
	 * @return if the spot targeted is occupied
	 */
	public boolean CheckOccupied(int x, int y){
		return TheGrid[x][y].IsOccupied();
	}
	/**
	 *  (Depreciated function?)
	 * @param TheShot
	 * @return a new shot for this grid at the coordinate 0,0
	 */
	public Shot PlayerAttack(Shot TheShot){
		return new Shot (this,0,0);
	}
	/**
	 * 
	 * @param x the x location on the grid
	 * @param y the y location on the grid
	 * @return if the shot was a hit
	 */
	public boolean Attack(int x, int y) {
		TheGrid[x][y].FireAt();
		return TheGrid[x][y].Hit();
	}
	
}